<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div {
            width: 200px;
            height: 200px;
            background-color: pink;
        }
    </style>
</head>

<body>

    <div></div>
</body>

<script>
    let div = document.querySelector('div');
    window.addEventListener('resize', function() {
        console.log('变化了');
        console.log(window.innerWidth);
        if (window.innerWidth < 800) {
            div.style.display = 'none';
        } else {
            div.style.display = 'block';
        }
    })
</script>

</html>